import requests
# -*- encoding:utf-8 -*-
if __name__ == '__main__':
    url = 'http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=keyword'
    op = input('enter a word:')
    params = {
        'cname':'',
        'pid':'',
        'keyword':op,
        'pageIndex':'1',
        'pageSize':'10',
    }
    headers = {
        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.54'
    }
    response = requests.post(url=url,data=params,headers=headers)
    page_text=response.text
    fileName = op + '.text'
    with open(fileName, 'w', encoding='utf-8') as fp:
        fp.write(page_text)